



class Node:
    def __init__(self,value,next=None):
        self.value = value
        self.next = next

    @property
    def value(self):
        return self.__value


    @value.setter
    def value(self,value):
        '''
        只要大于0的数
        :param value:
        :return:
        '''
        if value <= 0 :
            raise ValueError("列表中有<=0的数，我不要")
        else:
            self.__value = value


def list2node(target):
    try:
        A = Node(target[0])
    except ValueError:
        return '值错误，会不会用呀，呆瓜'
    B=A
    for i in range(1,len(target)):
        B.next = Node(target[i])
        B = B.next
    return A

def print_node(target):
    target1 = target
    while target1:
        try:
            print(target1.value)
            target1 = target1.next
        except AttributeError:
            print('没这个属性呀，老哥')
            return


class Lian:
    '''
    合并两个有序列表
    '''
    def merge(self, l1, l2):
        if not l1: return l2
        if not l2: return l1
        if l1.value <= l2.value:
            l1.next = self.merge(l1.next, l2)
            return l1
        else:
            l2.next = self.merge(l1, l2.next)
            return l2


if __name__ == '__main__':
    a1 = [1, 3,5, 7, 9]
    a2 = [2,4,6,8,10]
    b1 = list2node(a1)
    b2 = list2node(a2)
    print_node(b1)
    print('-'*15)
    print_node(b2)
    print('-' * 15)
    A= Lian()
    m = A.merge(b1, b2)
    print_node(m)
    # print(b)
    # print_node(b)


